<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Welcome!</title>
    
	
    <SCRIPT src="js/jquery.min.js" type="text/javascript"></SCRIPT>
    <SCRIPT src="js/moment.js" type="text/javascript"></SCRIPT>
    <SCRIPT src="js/bootstrap-datetimepicker.js" type="text/javascript"></SCRIPT>
    <SCRIPT src="js/bootstrap-datetimepicker.ru.js" type="text/javascript"></SCRIPT>
    <link href="css/bootstrap.min.css" rel="stylesheet">
	<link rel="stylesheet" href="css/bootstrap-datetimepicker.min.css">
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<script type="text/javascript" src="js/moment.js"></script>
	<script src="js/bootstrap3-typeahead.js"></script> 
	
	
	<!-- my style -->
	<link href="css/dopstyle.css" rel="stylesheet">

<%@page import="java.util.ArrayList"%>
<%@page import="javax.ejb.EJB"%>
<%@page import="ejb.CityRepositoryBean;"%>

<jsp:useBean id="CityRepositoryBean" class="ejb.CityRepositoryBean"/>

<%	
String cities = "";		
ArrayList<entities.City> city = CityRepositoryBean.getAllCities();
for (int i=0; i<city.size(); i++){
	cities += "\""+ city.get(i).getCityName() +"\", ";
}
if (cities.length() != 0) cities = cities.substring(0, cities.length()-2);
%>

</head>
<body class="bg">

   
<script> <!-- for inputs-->
	$(function () {
	var cities = [<%= cities %>];
	$('#from').typeahead({source: cities});
	$('#where').typeahead({source: cities});
	$('#date').datetimepicker({language: 'ru', pickTime: false});
    });
</script>

 
    <div class="container">
    
      <div class="header">
        <ul class="nav nav-pills pull-right">
          <%@ include file="LoginForm.jsp" %>
        </ul>
        <h3 class="text-muted"> </h3><!-- Project name -->
      </div>

      <div class="jumbotron"> <!-- main -->
		<h1>Полетели?</h1>
		<form class="form-horizontal" role="form" method="Get" action="/NCProjectWeb/FlightsList.jsp">
		
		<div class="row">
			 <!--откуда-->
			<div class="col-xs-5">
				<input id="from" name="from" type="text" class="form-control" data-provide="typeahead" placeholder="Откуда летим?" autocomplete="off" required>		
			</div>		
			<div class="col-xs-2">
				<div class="input-group date" id="date">
				<input class="form-control" name="when" type="text" placeholder="когда?" autocomplete="off" required>                    
				<SPAN class="input-group-addon">
					<SPAN class="glyphicon glyphicon-calendar"></SPAN>
				</SPAN> 
				</DIV>
			</div>		
			<!--куда-->
			<div class="col-xs-5 pull-right">
				<input id="where" name="where" type="text" class="form-control" data-provide="typeahead" placeholder="Куда летим?" autocomplete="off" required>
			</div>
		</div>
		
		
		<br> <!-- button -->
		<div class="col-sm-offset-5 col-sm-6">
		<button  class="btn btn-default">Найти</button> 
		</div>
		
		  </div>
		</form>
        	   
      </div> <!--конец контейнера-->
	
    <!-- footer -->
	<div id="footer">
      <div class="container">
        <p class="text-muted">Сайт поддерживается единорогами 2014(с)</p>
       </div>
    </div>
	
  </body>
</html>